﻿using AiShow.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.SessionState;

namespace AiShow.WebSite
{
    /// <summary>
    /// 图片验证码处理程序
    /// </summary>
    public class CaptchaHandler : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            CaptchaGenerator captcha = new CaptchaGenerator(4,2);
            //context.Session["code"] =  captcha.Text;
            context.Session.Add("code", captcha.Text);
            captcha.Image.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
            context.Response.ContentType = "image/jpeg";
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}